package jdbc.way2;


import jdbc.connection.Connection;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.Properties;

public class Client {

    public static void main(String[] args) throws Exception {
        Class<?> clazz = getConnectionClass("mysql");
        Constructor<?> c = clazz.getConstructor(Properties.class);
        Connection connection = (Connection) c.newInstance(new Properties());
    }

    private static Class getConnectionClass(String type) throws Exception {
        Properties prop = new Properties();
        InputStream in = new BufferedInputStream(new FileInputStream("conn.properties"));
        prop.load(in);
        return Class.forName(prop.getProperty(type));
    }
}
